<?php
use yii\helpers\Url;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Redisman Login</title>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script type="text/javascript" src="/js/ajax141212.js"></script>
<script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script>
<style>

.inputdiv{
	height:30px;
	text-align:center;
	
}
</style>
</head>
<body>

<div style="width:500px; margin:0px auto; margin-top:200px; border:1px solid #CCC">
  <div class="inputdiv" style=" margin-top:20px;">用户名：<input type="text" id="username" value=""/></div>
  <div class="inputdiv">密　码：<input type="password" id="password" value=""/></div>
  <div style="text-align:center; margin-top:10px; margin-bottom:20px;"><input type="button" value="Login" style=" width:80px;height:30px;" onclick="login()"/></div>
</div>
<script language="javascript">


request = new Ajax();


function login(){
	
	var username = document.getElementById("username").value;
	var password = document.getElementById("password").value;
	
	
	request.post({
		url : "<?php echo Url::to(['/login/async-login'])?>",
		data : "username="+username+"&password="+password,
		resultType : "json",
		onLoaded : function(result){
			console.log(result);
			
			if(result.code == 1){
				window.location.href = "<?php echo Url::to(["practice/index"])?>";
			}else{
				alert(result.info);
			}
		}
	});
}


</script>
</body>
</html>